package com.google.code.fulltank.strategy;

import com.google.code.fulltank.FuelTank;
import com.google.code.fulltank.price.FuelPriceHistory;
import com.google.code.fulltank.usage.FuelUsageHistory;
import org.joda.time.LocalDate;

/**
 * Fueling strategy: determines when and how much to fuel given fuel price and
 * usage histories.
 * 
 * @author DL
 */
public abstract class FuelingStrategy {
    public FuelingStrategy(
        FuelTank tank, FuelPriceHistory prices, FuelUsageHistory usage) {

        this.tank = tank;
        this.prices = prices;
        this.usage = usage;
    }

    /**
     * Called sequentially for every date on the FuelUsageHistory. The strategy
     * must make sure that the FuelTank has enough fuel to last the day.
     * 
     * @param date   A date of the FuelUsageHistory period.
     * @return the amount of fuel to fill up (Double.POSITIVE_INFINITY to fill
     * up the tank, 0 for none).
     */
    public abstract double onDate(LocalDate date);

    protected final FuelTank tank;
    protected final FuelPriceHistory prices;
    protected final FuelUsageHistory usage;
}
